﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
using System.Collections;
using System.Data;
using BusinessObjects.BO_GetObjects;

/// <summary>
/// Summary description for ProductServices
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class ProductServices : System.Web.Services.WebService
{

    public ProductServices()
    {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod()]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public IEnumerable GetItemsByModule()
    {
        List<Product> FieldProducts = new List<Product>();
        DataTable objDT = BO_Products.SelectByModule(1, 1, 10, 1);
        foreach (DataRow item in objDT.Rows)
        {
            FieldProducts.Add(new Product() { Product_id = Convert.ToInt64(item["PRODUCT_ID"].ToString()), Product_name = item["PRODUCT_NAME"].ToString(), Product_description = item["PRODUCT_DESCRIPTION"].ToString(), Thumb_img = item["THUMB_IMG"].ToString() });
        }
        return FieldProducts.AsEnumerable();
    }
   
}
